home *** CD-ROM | disk | FTP | other *** search
/ Canadian Geographic Explorer / Canadian Geographic Explorer.iso / pc / riddler.dxr / 00002_Misc Handlers.ls < prev    next >
Encoding:
Text File  |  1996-10-03  |  8.6 KB  |  250 lines

  1. on dostartMovie
  2.   global gNumPlayers, gPathToSound, fileDelimiter, gMusicChannel, gVoiceChannel, gSoundFXChannel, gAnimObj, gCurrQuestion, gQAnimFirst, gQAnimLength, gTenQList, gTextFileID, gTextData, gValueSprite, gCatSprite, gKeyList, gScoreList, gName1Sprite, gName2Sprite, gName3Sprite, gScore1Sprite, gScore2Sprite, gScore3Sprite, gPlayerCounter, gNullCast, gNumOfQuestions, gNumOfTotalQuestions, gStaticAllQuestList, gDynamicAllQuestList
  3.   clearGlobals()
  4.   unloadMember()
  5.   KillEmPuppets()
  6.   set gNumOfQuestions to 10
  7.   set gNumOfTotalQuestions to 94
  8.   set gNullCast to the number of member "Null Cast"
  9.   set gName1Sprite to 28
  10.   set gName2Sprite to 29
  11.   set gName3Sprite to 30
  12.   set gScore1Sprite to 31
  13.   set gScore2Sprite to 32
  14.   set gScore3Sprite to 33
  15.   set gValueSprite to 10
  16.   set gCatSprite to 11
  17.   set gNumPlayers to 0
  18.   set gPlayerCounter to 0
  19.   set gScoreList to [0, 0, 0]
  20.   set gCurrQueston to 0
  21.   set gKeyList to ["a", "b", "l"]
  22.   set the castLibNum of sprite gCatSprite to the number of castLib "categories and point values"
  23.   set the castLibNum of sprite gValueSprite to the number of castLib "categories and point values"
  24.   set gStaticAllQuestList to []
  25.   repeat while count(gStaticAllQuestList) < gNumOfTotalQuestions
  26.     set jRandom to random(gNumOfTotalQuestions)
  27.     if not getPos(gStaticAllQuestList, jRandom) then
  28.       add(gStaticAllQuestList, jRandom)
  29.     end if
  30.   end repeat
  31.   set gDynamicAllQuestList to duplicate(gStaticAllQuestList)
  32.   set gQAnimFirst to []
  33.   repeat with i = 1 to gNumOfQuestions
  34.     add(gQAnimFirst, the number of member ("Quest" & i) of castLib "Question Titles")
  35.   end repeat
  36.   set gQAnimLength to [31, 31, 44, 30, 31, 50, 38, 31, 31, 36]
  37.   set gCurrQuestion to 0
  38.   case item 1 of the platform of
  39.     "Windows":
  40.       set fileDelimiter to "\"
  41.       set jFileName to "pcquest.txt"
  42.     "Macintosh":
  43.       set fileDelimiter to ":"
  44.       set jFileName to "macquest.txt"
  45.   end case
  46.   set gPathToSound to the pathName & "Audio" & fileDelimiter
  47.   set gMusicChannel to 2
  48.   set gVoiceChannel to 1
  49.   set gSoundFXChannel to 3
  50.   sound stop gMusicChannel
  51.   sound stop gVoiceChannel
  52.   sound stop gSoundFXChannel
  53.   set the volume of sound gMusicChannel to 255
  54.   set the volume of sound gVoiceChannel to 255
  55.   set the volume of sound gSoundFXChannel to 255
  56.   set the actorList to []
  57.   set gAnimObj to new(script "Anim Object Script", 35)
  58.   if item 1 of the platform = "Windows" then
  59.     openXLib("fileio.dll")
  60.   end if
  61.   set gTextFileID to FileIO(mnew, "read", the pathName & jFileName)
  62.   set gTextData to gTextFileID(mReadFile)
  63. end
  64.  
  65. on stopMovie
  66.   global gTextFileID, gMusicChannel, gVoiceChannel, gSoundFXChannel
  67.   if objectp(gTextFileID) then
  68.     gTextFileID(mdispose)
  69.   end if
  70.   unloadMember()
  71.   set the actorList to []
  72.   repeat with i = 1 to 48
  73.     if the puppet of sprite i then
  74.       puppetSprite(i, 0)
  75.     end if
  76.   end repeat
  77.   sound stop gMusicChannel
  78.   sound stop gVoiceChannel
  79.   sound stop gSoundFXChannel
  80.   set the volume of sound gMusicChannel to 255
  81.   set the volume of sound gVoiceChannel to 255
  82.   set the volume of sound gSoundFXChannel to 255
  83. end
  84.  
  85. on addZeroes x
  86.   set y to string(x)
  87.   set outString to y
  88.   repeat with i = 3 - length(y) down to 1
  89.     set outString to 0 & outString
  90.   end repeat
  91.   return outString
  92. end
  93.  
  94. on LingoPause pTicks
  95.   set jTime to the timer
  96.   repeat while the timer < (jTime + pTicks)
  97.   end repeat
  98. end
  99.  
  100. on KillEmPuppets
  101.   repeat with i = 1 to 48
  102.     if the puppet of sprite i then
  103.       puppetSprite(i, 0)
  104.     end if
  105.   end repeat
  106. end
  107.  
  108. on displayScores
  109.   global gNumPlayers, gName1Sprite, gName2Sprite, gName3Sprite, gScore1Sprite, gScore2Sprite, gScore3Sprite
  110.   case gNumPlayers of
  111.     1:
  112.       if not (the puppet of sprite gName1Sprite) then
  113.         puppetSprite(gName1Sprite, 1)
  114.       end if
  115.       set the memberNum of sprite gName1Sprite to the number of member "name1"
  116.       if not (the puppet of sprite gScore1Sprite) then
  117.         puppetSprite(gScore1Sprite, 1)
  118.       end if
  119.       set the memberNum of sprite gScore1Sprite to the number of member "player1 score"
  120.     2:
  121.       if not (the puppet of sprite gName1Sprite) then
  122.         puppetSprite(gName1Sprite, 1)
  123.       end if
  124.       set the memberNum of sprite gName1Sprite to the number of member "name1"
  125.       if not (the puppet of sprite gScore1Sprite) then
  126.         puppetSprite(gScore1Sprite, 1)
  127.       end if
  128.       set the memberNum of sprite gScore1Sprite to the number of member "player1 score"
  129.       if not (the puppet of sprite gName2Sprite) then
  130.         puppetSprite(gName2Sprite, 1)
  131.       end if
  132.       set the memberNum of sprite gName2Sprite to the number of member "name2"
  133.       if not (the puppet of sprite gScore2Sprite) then
  134.         puppetSprite(gScore2Sprite, 1)
  135.       end if
  136.       set the memberNum of sprite gScore2Sprite to the number of member "player2 score"
  137.     3:
  138.       if not (the puppet of sprite gName1Sprite) then
  139.         puppetSprite(gName1Sprite, 1)
  140.       end if
  141.       set the memberNum of sprite gName1Sprite to the number of member "name1"
  142.       if not (the puppet of sprite gScore1Sprite) then
  143.         puppetSprite(gScore1Sprite, 1)
  144.       end if
  145.       set the memberNum of sprite gScore1Sprite to the number of member "player1 score"
  146.       if not (the puppet of sprite gName2Sprite) then
  147.         puppetSprite(gName2Sprite, 1)
  148.       end if
  149.       set the memberNum of sprite gName2Sprite to the number of member "name2"
  150.       if not (the puppet of sprite gScore2Sprite) then
  151.         puppetSprite(gScore2Sprite, 1)
  152.       end if
  153.       set the memberNum of sprite gScore2Sprite to the number of member "player2 score"
  154.       if not (the puppet of sprite gName3Sprite) then
  155.         puppetSprite(gName3Sprite, 1)
  156.       end if
  157.       set the memberNum of sprite gName3Sprite to the number of member "name3"
  158.       if not (the puppet of sprite gScore3Sprite) then
  159.         puppetSprite(gScore3Sprite, 1)
  160.       end if
  161.       set the memberNum of sprite gScore3Sprite to the number of member "player3 score"
  162.   end case
  163. end
  164.  
  165. on BuzzInHandler
  166.   global gWhoBuzzedIn, gNumPlayers, gKeyList, gVoiceChannel, gPathToSound, fileDelimiter, gSoundFXChannel
  167.   set jKey to the keyPressed
  168.   if (jKey = "a") or ((jKey = "A") and (gWhoBuzzedIn <> 1)) then
  169.     sound playFile gSoundFXChannel, gPathToSound & "soundfx" & fileDelimiter & "click.aif"
  170.     sound playFile gVoiceChannel, gPathToSound & "qanda" & fileDelimiter & "player1.aif"
  171.     set gWhoBuzzedIn to 1
  172.   else
  173.     if (jKey = "b") or ((jKey = "B") and (gNumPlayers > 1) and (gWhoBuzzedIn <> 2)) then
  174.       sound playFile gSoundFXChannel, gPathToSound & "soundfx" & fileDelimiter & "click.aif"
  175.       sound playFile gVoiceChannel, gPathToSound & "qanda" & fileDelimiter & "player2.aif"
  176.       set gWhoBuzzedIn to 2
  177.     else
  178.       if (jKey = "l") or ((jKey = "L") and (gNumPlayers > 2) and (gWhoBuzzedIn <> 3)) then
  179.         sound playFile gSoundFXChannel, gPathToSound & "soundfx" & fileDelimiter & "click.aif"
  180.         sound playFile gVoiceChannel, gPathToSound & "qanda" & fileDelimiter & "player3.aif"
  181.         set gWhoBuzzedIn to 3
  182.       else
  183.         exit
  184.       end if
  185.     end if
  186.   end if
  187.   sound playFile gSoundFXChannel, gPathToSound & "soundFX" & fileDelimiter & "ticking2.aif"
  188.   go(marker(1))
  189. end
  190.  
  191. on Capitalize pField
  192.   set jChar to charToNum(char 1 of field pField)
  193.   if (jChar < 123) and (jChar > 96) then
  194.     case jChar of
  195.       97:
  196.         put "A" into char 1 of field pField
  197.       98:
  198.         put "B" into char 1 of field pField
  199.       99:
  200.         put "C" into char 1 of field pField
  201.       100:
  202.         put "D" into char 1 of field pField
  203.       101:
  204.         put "E" into char 1 of field pField
  205.       102:
  206.         put "F" into char 1 of field pField
  207.       103:
  208.         put "G" into char 1 of field pField
  209.       104:
  210.         put "H" into char 1 of field pField
  211.       105:
  212.         put "I" into char 1 of field pField
  213.       106:
  214.         put "J" into char 1 of field pField
  215.       107:
  216.         put "K" into char 1 of field pField
  217.       108:
  218.         put "L" into char 1 of field pField
  219.       109:
  220.         put "M" into char 1 of field pField
  221.       110:
  222.         put "N" into char 1 of field pField
  223.       111:
  224.         put "O" into char 1 of field pField
  225.       112:
  226.         put "P" into char 1 of field pField
  227.       113:
  228.         put "Q" into char 1 of field pField
  229.       114:
  230.         put "R" into char 1 of field pField
  231.       115:
  232.         put "S" into char 1 of field pField
  233.       116:
  234.         put "T" into char 1 of field pField
  235.       117:
  236.         put "U" into char 1 of field pField
  237.       118:
  238.         put "V" into char 1 of field pField
  239.       119:
  240.         put "W" into char 1 of field pField
  241.       120:
  242.         put "X" into char 1 of field pField
  243.       121:
  244.         put "Y" into char 1 of field pField
  245.       122:
  246.         put "Z" into char 1 of field pField
  247.     end case
  248.   end if
  249. end
  250.